//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.mopub.nativeads;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import java.util.HashSet;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;

public abstract class BaseNativeAd {
    @NonNull
    private final Set<String> mImpressionTrackers = new HashSet();
    @NonNull
    private final Set<String> mClickTrackers = new HashSet();
    @Nullable
    private BaseNativeAd.NativeEventListener mNativeEventListener;

    protected BaseNativeAd() {
    }

    public abstract void prepare(@NonNull View var1);

    public abstract void clear(@NonNull View var1);

    public abstract void destroy();

    public void setNativeEventListener(@Nullable BaseNativeAd.NativeEventListener nativeEventListener) {
        this.mNativeEventListener = nativeEventListener;
    }

    protected final void notifyAdImpressed() {
        if (this.mNativeEventListener != null) {
            this.mNativeEventListener.onAdImpressed();
        }

    }

    protected final void notifyAdClicked() {
        if (this.mNativeEventListener != null) {
            this.mNativeEventListener.onAdClicked();
        }

    }

    protected final void addImpressionTrackers(Object impressionTrackers) throws ClassCastException {
        if (!(impressionTrackers instanceof JSONArray)) {
            throw new ClassCastException("Expected impression trackers of type JSONArray.");
        } else {
            JSONArray trackers = (JSONArray)impressionTrackers;

            for(int i = 0; i < trackers.length(); ++i) {
                try {
                    this.addImpressionTracker(trackers.getString(i));
                } catch (JSONException var5) {
                }
            }

        }
    }

    protected final void addClickTrackers(Object clickTrackers) throws ClassCastException {
        if (!(clickTrackers instanceof JSONArray)) {
            throw new ClassCastException("Expected click trackers of type JSONArray.");
        } else {
            JSONArray trackers = (JSONArray)clickTrackers;

            for(int i = 0; i < trackers.length(); ++i) {
                try {
                    this.addClickTracker(trackers.getString(i));
                } catch (JSONException var5) {
                }
            }

        }
    }

    public final void addImpressionTracker(@NonNull String url) {
        this.mImpressionTrackers.add(url);
    }

    public final void addClickTracker(@NonNull String url) {
        this.mClickTrackers.add(url);
    }

    @NonNull
    Set<String> getImpressionTrackers() {
        return new HashSet(this.mImpressionTrackers);
    }

    @NonNull
    Set<String> getClickTrackers() {
        return new HashSet(this.mClickTrackers);
    }

    public interface NativeEventListener {
        void onAdImpressed();

        void onAdClicked();
    }
}
